home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / File / Hide ⁄ Show < prev    next >
Encoding:
Text File  |  1999-03-04  |  2.2 KB  |  118 lines  |  [TEXT/ToyS]

  1. -- Preferences
  2. property kasPrefName : "Hide / Show 1.0"
  3.  
  4. -- Globals
  5. global gasInfoWind -- Info window
  6. global gasInfoPos -- Position of info window
  7. global gasDid -- Number gone!
  8. global gasChecked -- Number checked!
  9. global gasWanted -- What you want
  10. global gasItems -- Stored list of items we've set invisible
  11.  
  12.  
  13. on run
  14.     open {}
  15. end run
  16.  
  17.  
  18. on open fsObjs
  19.     -- Load prefs, show window
  20.     pfLoad()
  21.     
  22.     if (fsObjs is {}) then
  23.         set fsObjs to gasItems
  24.         set gasItems to {}
  25.         set gasWanted to false -- Invisibility off
  26.         set msg to "Revealing past items…"
  27.     else
  28.         set gasWanted to true -- Make invisible
  29.         set msg to "Hiding selected items…"
  30.     end if
  31.     
  32.     set gasDid to 0
  33.     set gasChecked to 0
  34.     
  35.     set gasInfoWind to display info titled kasPrefName ¬
  36.         located at gasInfoPos ¬
  37.         message msg
  38.     
  39.     -- Do files
  40.     repeat with fsObj in fsObjs
  41.         DoOne(fsObj)
  42.         if gasWanted then
  43.             set gasItems to gasItems & {fsObj}
  44.             pfSave()
  45.         end if
  46.     end repeat
  47.     
  48.     display info gasInfoWind message "DONE (" & msg & ")"
  49.     
  50.     pause for 5 with seconds timing -- Let screen wait...
  51.     
  52.     set gasInfoPos to screen location of ¬
  53.         (display info gasInfoWind with disposal)
  54.     
  55.     pfSave() -- Save window location
  56. end open
  57.  
  58.  
  59. on DoOne(fsObj)
  60.     try
  61.         set myInfo to (extended info for fsObj)
  62.     on error
  63.         beep
  64.         return
  65.     end try
  66.     
  67.     display info gasInfoWind ¬
  68.         message "File: " & (catalog name of myInfo) ¬
  69.         at line 2
  70.     
  71.     set gasChecked to gasChecked + 1
  72.     
  73.     set invisible status of myInfo to gasWanted
  74.     
  75.     try
  76.         set the catalog info of fsObj to myInfo
  77.         set gasDid to gasDid + 1
  78.         display info gasInfoWind ¬
  79.             message ("Did: " & gasDid) ¬
  80.             at line 6 ¬
  81.             using color 15 * 32
  82.     on error
  83.         beep
  84.     end try
  85.     
  86.     set myInfo to (extended info for fsObj)
  87.     
  88.     if (invisible status of myInfo) is not gasWanted then
  89.         display info gasInfoWind ¬
  90.             message ("Couldn't change status") ¬
  91.             at line 5 ¬
  92.             using color 15 * 32 * 32
  93.         beep
  94.     end if
  95.     
  96.     display info gasInfoWind ¬
  97.         message ("Checked: " & gasChecked) ¬
  98.         at line 7 ¬
  99.         using color 15
  100. end DoOne
  101.  
  102.  
  103. on pfLoad()
  104.     try
  105.         set ourPrefs to (load preference named kasPrefName)
  106.     on error
  107.         set ourPrefs to {{0, 0}, {}}
  108.     end try
  109.     
  110.     set gasInfoPos to item 1 of ourPrefs
  111.     set gasItems to item 2 of ourPrefs
  112. end pfLoad
  113.  
  114.  
  115. on pfSave()
  116.     save preference {gasInfoPos, gasItems} named kasPrefName
  117. end pfSave
  118.